/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;

/**
 *
 * @author johnny
 */
@Entity
@Indexed
@Table(catalog = "celulares", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cliente.findAll", query = "SELECT c FROM Cliente c"),
    @NamedQuery(name = "Cliente.findByCedula", query = "SELECT c FROM Cliente c WHERE c.cedula = :cedula"),
    @NamedQuery(name = "Cliente.findByApellidos", query = "SELECT c FROM Cliente c WHERE c.apellidos = :apellidos"),
    @NamedQuery(name = "Cliente.findByDireccion", query = "SELECT c FROM Cliente c WHERE c.direccion = :direccion"),
    @NamedQuery(name = "Cliente.findByEmail", query = "SELECT c FROM Cliente c WHERE c.email = :email"),
    @NamedQuery(name = "Cliente.findByEstado", query = "SELECT c FROM Cliente c WHERE c.estado = :estado"),
    @NamedQuery(name = "Cliente.findByNombres", query = "SELECT c FROM Cliente c WHERE c.nombres = :nombres"),
    @NamedQuery(name = "Cliente.findByTelefono", query = "SELECT c FROM Cliente c WHERE c.telefono = :telefono")})
public class Cliente
  implements Serializable
{
  private static final long serialVersionUID = 1L;

  @Id
  @Basic(optional=false)
  @Column(nullable=false, length=13)
  @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
  private String cedula;

  @Column(length=45)
  @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
  private String apellidos;

  @Column(length=45)
  @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
  private String direccion;

  @Column(length=45)
  @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
  private String email;

  @Column(length=45)
  private String estado;

  @Column(length=45)
  @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
  private String nombres;

  @Column(length=45)
  @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
  private String telefono;

  @OneToMany(mappedBy="cedulaCliente")
  private List<Deuda> deudaList;

  @OneToMany(cascade={javax.persistence.CascadeType.ALL}, mappedBy="cedulaCliente")
  private List<ServicioTecnico> servicioTecnicoList;

  @OneToMany(cascade={javax.persistence.CascadeType.ALL}, mappedBy="cedulaCliente")
  private List<Proforma> proformaList;

  @OneToMany(cascade={javax.persistence.CascadeType.ALL}, mappedBy="cedulaCliente")
  private List<Factura> facturaList;

  public Cliente()
  {
  }

  public Cliente(String cedula)
  {
    this.cedula = cedula;
  }

  public String getCedula() {
    return this.cedula;
  }

  public void setCedula(String cedula) {
    this.cedula = cedula;
  }

  public String getApellidos() {
    return this.apellidos;
  }

  public void setApellidos(String apellidos) {
    this.apellidos = apellidos;
  }

  public String getDireccion() {
    return this.direccion;
  }

  public void setDireccion(String direccion) {
    this.direccion = direccion;
  }

  public String getEmail() {
    return this.email;
  }

  public void setEmail(String email) {
    this.email = email;
  }

  public String getEstado() {
    return this.estado;
  }

  public void setEstado(String estado) {
    this.estado = estado;
  }

  public String getNombres() {
    return this.nombres;
  }

  public void setNombres(String nombres) {
    this.nombres = nombres;
  }

  public String getTelefono() {
    return this.telefono;
  }

  public void setTelefono(String telefono) {
    this.telefono = telefono;
  }
  @XmlTransient
  @JsonIgnore
  public List<Deuda> getDeudaList() {
    return this.deudaList;
  }

  public void setDeudaList(List<Deuda> deudaList) {
    this.deudaList = deudaList;
  }
  @XmlTransient
  @JsonIgnore
  public List<ServicioTecnico> getServicioTecnicoList() {
    return this.servicioTecnicoList;
  }

  public void setServicioTecnicoList(List<ServicioTecnico> servicioTecnicoList) {
    this.servicioTecnicoList = servicioTecnicoList;
  }
  @XmlTransient
  @JsonIgnore
  public List<Proforma> getProformaList() {
    return this.proformaList;
  }

  public void setProformaList(List<Proforma> proformaList) {
    this.proformaList = proformaList;
  }
  @XmlTransient
  @JsonIgnore
  public List<Factura> getFacturaList() {
    return this.facturaList;
  }

  public void setFacturaList(List<Factura> facturaList) {
    this.facturaList = facturaList;
  }

  public int hashCode()
  {
    int hash = 0;
    hash += (this.cedula != null ? this.cedula.hashCode() : 0);
    return hash;
  }

  public boolean equals(Object object)
  {
    if (!(object instanceof Cliente)) {
      return false;
    }
    Cliente other = (Cliente)object;
    if (((this.cedula == null) && (other.cedula != null)) || ((this.cedula != null) && (!this.cedula.equals(other.cedula)))) {
      return false;
    }
    return true;
  }

  public String toString()
  {
    return "com.mycompany.entidades.Cliente[ cedula=" + this.cedula + " ]";
  }
}